//
//  UINavigationController+BarBaseAppearce.m
//  YYK
//
//  Created by xiexianyu on 1/29/15.
//  Copyright (c) 2015 39.net. All rights reserved.
//

#import "UINavigationController+BarBaseAppearce.h"
#import "QISBaseNavigationController.h"

@implementation UINavigationController (BarBaseAppearce)

// set navi bar tint color, bar tint color, and title font and color.
- (void)configureNavigationBarBaseAppearce
{
    // navi bar bk
    UIColor *naviBarTintColor = [UIColor whiteColor];
    self.navigationBar.barTintColor = naviBarTintColor;
    
    // navi bar title font and color
    UIFont *titleFont = [UIFont boldSystemFontOfSize:18.0];
    UIColor *titleColor = [UIColor colorWithRed:81/255.0 green:91/255.0 blue:102/255.0 alpha:1.0];
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:titleColor, NSFontAttributeName:titleFont};
    //
    self.navigationBar.titleTextAttributes = titleTextAttributes;
    
    self.navigationBar.translucent = YES;
    [self.navigationBar setShadowImage:[UIImage new]]; // clear shadow
}

-(void)configureHomeNavigationBarNavigationBar {
    // navi bar bk
    UIColor *naviBarTintColor = [UIColor colorWithRed:238/255.0 green:239/255.0 blue:241/255.0 alpha:0.0];
    self.navigationBar.barTintColor = naviBarTintColor; //bar bk color
    
    // navi bar title font and color
    UIFont *titleFont = [UIFont boldSystemFontOfSize:18.0];
    UIColor *titleColor = [UIColor whiteColor];
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:titleColor, NSFontAttributeName:titleFont};
    //
    self.navigationBar.titleTextAttributes = titleTextAttributes;
}

// for messageCenter tab
- (void)configureNormalNavigationBar {
    // navi bar bk
    //UIColorFromRGB(0xEEEFF1)
    UIColor *naviBarTintColor = RGBCOLOR(193, 3, 3);
    self.navigationBar.barTintColor = naviBarTintColor; //bar bk color
    
    // navi bar title font and color
    UIFont *titleFont = [UIFont boldSystemFontOfSize:18.0];
    //UIColor *titleColor = [UIColor colorWithRed:81/255.0 green:91/255.0 blue:102/255.0 alpha:1.0];
    UIColor *titleColor = [UIColor whiteColor];
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:titleColor, NSFontAttributeName:titleFont};
    //
    self.navigationBar.titleTextAttributes = titleTextAttributes;
    self.navigationBar.translucent = NO;
    //iOS11以下，移除导航栏底部横线
    [self.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
}



- (void)resetNextPageNavigationBar
{
    // navi bar bk
    UIColor *naviBarTintColor = [UIColor whiteColor];
    self.navigationBar.barTintColor = naviBarTintColor; //bar bk color
    
    // navi bar title font and color
    UIFont *titleFont = [UIFont boldSystemFontOfSize:18.0];
    UIColor *titleColor = [UIColor colorWithRed:81/255.0 green:91/255.0 blue:102/255.0 alpha:1.0];
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:titleColor, NSFontAttributeName:titleFont};
    //
    self.navigationBar.titleTextAttributes = titleTextAttributes;
    //iOS11以下
    [self.navigationBar setBackgroundImage:nil forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
}

// navi bar for info edit module page.
- (void)configureInfoEditModuleNavigationBarBaseAppearce
{
    // navi bar bk
    UIColor *naviBarTintColor = [UIColor colorWithRed:238/255.0 green:239/255.0 blue:241/255.0 alpha:1.0];
    //
    self.navigationBar.barTintColor = naviBarTintColor; //bar bk color
    
    // navi bar title font and color
    UIFont *titleFont = [UIFont boldSystemFontOfSize:18.0];
    UIColor *titleColor = [UIColor colorWithRed:81/255.0 green:91/255.0 blue:102/255.0 alpha:1.0];
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:titleColor, NSFontAttributeName:titleFont};
    //
    self.navigationBar.titleTextAttributes = titleTextAttributes;
    
    self.navigationBar.translucent = NO;
    [self.navigationBar setShadowImage:[UIImage new]]; // clear shadow
}

- (void)configureHistoryStepNavigationBar {
    // navi bar bk
    UIColor *naviBarTintColor = UIColorFromRGB(0xEDF0F0);
    self.navigationBar.barTintColor = naviBarTintColor; //bar bk color
    
    // navi bar title font and color
    UIFont *titleFont = [UIFont boldSystemFontOfSize:18.0];
    UIColor *titleColor = [UIColor colorWithRed:81/255.0 green:91/255.0 blue:102/255.0 alpha:1.0];
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:titleColor, NSFontAttributeName:titleFont};
    //
    self.navigationBar.titleTextAttributes = titleTextAttributes;
    self.navigationBar.translucent = NO;
    //iOS11以下，移除导航栏底部横线
    [self.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    [self.navigationBar setShadowImage:[UIImage new]]; // clear shadow
}

#pragma mar - navi bar back image
- (void)configureNavigationBarBackImageWhite {
    // for Xcode9
    UIImage *bkImage = [[UIImage imageNamed:@"navi_back_white"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationBar.backIndicatorImage = bkImage;
    self.navigationBar.backIndicatorTransitionMaskImage = bkImage;
}

- (void)configureNavigationBarBackImageWithName:(NSString*)imageName {
    // for Xcode9
    UIImage *bkImage = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationBar.backIndicatorImage = bkImage;
    self.navigationBar.backIndicatorTransitionMaskImage = bkImage;
}


@end
